
CC = riscv64-unknown-elf-gcc
OBJCOPY = riscv64-unknown-elf-objcopy
OBJDUMP = riscv64-unknown-elf-objdump
SIZE = riscv64-unknown-elf-size
CCFLAG = -Wall -Wundef -Wno-format -fomit-frame-pointer -fno-builtin -ffunction-sections -fdata-sections -mabi=ilp32 -march=rv32i -fpic -O2

all :
	$(CC) $(CCFLAG) -c crc8_d.c
	$(CC) $(CCFLAG) -c crc8_d_table.S
	$(CC) $(CCFLAG) -nostdlib -nostartfiles -Tlinker.ld -Wl,-Map=crc8_d.map -o crc8_d.elf crc8_d.o crc8_d_table.o
	$(OBJCOPY) -g -O binary crc8_d.elf crc8_d.bin
	$(OBJDUMP) -d crc8_d.elf > crc8_d.asm
	$(SIZE) crc8_d.elf
	./bin2c.sh < crc8_d.bin > crc8_d.inc

clean:
	rm -fr *.asm *.o *.map *.elf *.bin *.inc 